<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Util
 *
 * @author minhhq
 */
class MKT_Util {

    static public function getConfig($key, $config_name = 'application') {
        $config = new Zend_Config_Ini(APPLICATION_PATH . "/configs/$config_name.ini");
        $temp = $config->get('production')->toArray();
        return $temp[$key];
    }
    
    static public function isDebugMode() {
        return APPLICATION_ENV == 'development';
    }
    
    static public function getFirstDayOfWeek($time) {
        $offset = date('N', $time) - 1;
        return strtotime("-$offset days", $time);
    }
    
    static public function getLastDayOfWeek($time) {
        $offset = 7 - date('N', $time);
        return strtotime("+$offset days", $time);
    }
    
    static public function getFirstDayOfMonth($time) {
        $month = date('m', $time);
        $year = date('Y', $time);
        return mktime(0, 0, 0, $month, 1, $year);
    }
    
    static public function getLastDayOfMonth($time) {
        $next_month = mktime(0,0,0, date('m', strtotime("+1 months", $time)), 1, date('Y', $time));
        return strtotime("-1 days", $next_month);
    }
    
    static public function isFacebookRequest ()
    {
        $is_fb_request = false;
        if ($_SERVER['HTTP_USER_AGENT'] ==
         "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)") {
            $is_fb_request = true;
        }
        return $is_fb_request;
    }    

}

?>
